<?php
namespace Home\Controller;
use Think\Controller;
class PublicController extends CommonController {
    public function login(){
		session("mid")?$this->redirect("Merchant/index"):$this->display();		
	}
	
	/**
	*登录账户	
	*/	
	public function checkin(){
		//先核对验证码
		$this->checkCode();
		$con['mh_id']=I('mid');
		$con['mh_isactive']=1;		
		$result=M("merchant")->where($con)->find();
		//echo md5(I('pwd').$result['mh_salt']);exit;
		
		if(!$result || md5(I('pwd').$result['mh_salt'])!=$result['mh_pwd'])
			$this->error(L("invalid_login"));
		
			session("mid",$result['mh_id']);
			$this->success(L("login_success"),U('Merchant/index'));
	}
	
	public function logout(){
		session("mid",null);
		$this->success(L("logout_success"),U('Index/index'));
	}
	
	//根据国家代码返回州
	public function getState(){
		I("iso")==3?$iso=3:$iso=2;
		$this->ajaxReturn(parent::getState(I("country_name"),$iso));
	}
	
	//异步通知测试地址
	public function asyn(){
		$oop=M("innotice");
		$data['in_oid']=$_POST['pid']."|432";
		$data['in_title']=$_POST['pid']."|555";
		$data['in_content']=dump(I(),false);
		$oop->add($data);	
		echo 100;
	}
}

